package com.itheima.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

//配置过滤器
/*
 * /login :拦截具体路径
 * @WebFilter(urlPatterns = "/*")
 *  :拦截所有
 *  /??/* :拦截目录
 *
 */
//@WebFilter(urlPatterns = "/*")
public class kunkunFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("init...初始化方法，执行一次，资源的加载操作");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("doFilter...过滤器核心方法，拦截每一次请求");
        System.out.println("1.放行前~~~~~");
        //核心操作：放行操作2
        System.out.println(".放行前~~~~");
        filterChain.doFilter(servletRequest, servletResponse);
        System.out.println("4.放行前~~~~");
    }

    @Override
    public void destroy() {
        System.out.println("destroy...销毁方法，执行一次，资源释放操作");
    }
}
